package helper

import "errors"

func GenerateCheckXOR(source []byte) (byte, error) {
	if len(source) < 2 {
		return 0, errors.New("generate check sum fail, source too short")
	}

	checkByte := source[0]
	for i := 1; i < len(source); i++ {
		checkByte ^= source[i]
	}
	return checkByte, nil
}
